// @FileName  :matrix.c
// @Time      :2024/2/29 20:26
// @Author    :YKW
//# include <bits/stdc++.h>
//using namespace std;
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <string.h>
# include <stdlib.h>

void solve() {
    char op;
    int a[100][100], n, tmp;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            scanf("%d", &a[i][j]);
    while (1) {
        scanf("%c", &op);
        if (op == '#') break;
        else if (op == '+') {
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++) {
                    scanf("%d", &tmp);
                    a[i][j] += tmp;
                }
        } else if (op == '-') {
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++) {
                    scanf("%d", &tmp);
                    a[i][j] -= tmp;
                }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            printf("%5d", a[i][j]);
        }
        printf("\n");
    }
}

void main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) solve();
    return 0;
}